package com.springstudy.processor;


import com.springstudy.dao.UserDao;
import com.springstudy.dao.impl.UserDaoImpl;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;

/**
 * @author Tamako
 * @since 2025/1/6 14:45
 */
public class MyBeanPostProcessor implements BeanPostProcessor {
    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
//        if(bean instanceof UserDao){
//            UserDaoImpl userDao=(UserDaoImpl) bean;
//            userDao.setUsername("admin");
//        }
        System.out.println(beanName + " before initialization");
        return bean;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        System.out.println(beanName + " after initialization");
        return bean;
    }
}
